package com.szrt.day20170415.ch03;

public class PetDaoImpl implements  PetDao {

	@Override
	public boolean addPet(PetShop huayun, Pet pet) {
		
		boolean flag=false;
		
		//1 得到放置宠物的笼子
		Pet[] pets = huayun.getPets();
		
		int counter=0;
		for(int index=0; index<pets.length;index++){
			Pet chongwu = pets[index];
			if(chongwu == null){
				break;
			}else{
				counter++;
			}
		}
		
		//counter 宠物的下标
		if(counter<=pets.length-1){
			
			pets[counter]=pet;
			flag=true;
		}else{
			System.out.println("满了....");
		}
		
		
		//2 看笼子满了没有
		
		//3 把宠物放进去
		
		return flag;
		
	}

}
